package com.phiture.erp.finance.common.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum ErpFinanceStatementTypeEnum {
    SUPPLIER_PAYMENT(1, "supplier_payment", "供应商付款"),
    CUSTOMER_RECEIPT(2, "customer_receipt", "客户收款");

    private final Integer type;
    private final String val;
    private final String desc;

    private static final Map<String, ErpFinanceStatementTypeEnum> VAL_MAP = new HashMap<>(4);
    private static final Map<Integer, ErpFinanceStatementTypeEnum> TYPE_MAP = new HashMap<>(4);
    static {
        for (ErpFinanceStatementTypeEnum value : values()) {
            VAL_MAP.put(value.val, value);
            TYPE_MAP.put(value.type, value);
        }
    }

    public static ErpFinanceStatementTypeEnum fromVal(String val){return VAL_MAP.get(val);}
    public static ErpFinanceStatementTypeEnum fromType(Integer type){return TYPE_MAP.get(type);}
    public static boolean isSupplier(Integer type){
        return SUPPLIER_PAYMENT == TYPE_MAP.get(type);
    }
    public static boolean isCustomer(Integer type){
        return CUSTOMER_RECEIPT == TYPE_MAP.get(type);
    }
}
